package com.sai.jsai.common.starter.mybatisplus.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sai.jsai.common.base.vo.PageParam;
import com.sai.jsai.common.base.vo.PageResult;
import org.apache.ibatis.annotations.Param;

/**
 * @author jisai
 * @version 0.0.1
 * @Description Mapper 基类
 * @createTime 2024/10/26
 */
public interface BaseMapper<T> extends com.baomidou.mybatisplus.core.mapper.BaseMapper<T> {

    default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) {
        Page<T> page = new Page<T>(pageParam.getPageNo(), pageParam.getPageSize());
        IPage<T> pageList = this.selectPage(page, queryWrapper);
        return new PageResult<>(pageList.getRecords(), pageList.getCurrent(), pageList.getSize(), pageList.getTotal(), pageList.getPages());
    }

}
